//
//  MyPinDanCell.m
//  jingjing2.0
//
//  Created by apple on 16/5/17.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "MyPinDanCell.h"

@implementation MyPinDanCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.backgroundColor=LIGHTGRAY;
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

- (IBAction)clickOnGetAward:(id)sender
{
    //领取奖励
    //http://192.168.1.107:3722/Activity/GetSpellReward
    //m_GetSpellRewardPara(UserCode,SpellUserID,Timestamp,Sign)
    UIButton *btn=sender;
    if ([[btn titleForState:UIControlStateNormal]isEqualToString:@"领取奖励"]) {
        NSString *timestamp=[GeneralTool gettimestamp];
        NSString *spellId=[NSString stringWithFormat:@"%zd",btn.tag];
        NSDictionary *dic=@{@"UserCode":GETUSERCODE,
                            @"SpellUserID":spellId,
                            @"Timestamp":timestamp,
                            };
        NSString *sign=[GeneralTool GetSin:dic];
        NSDictionary *dataDic=@{@"UserCode":GETUSERCODE,
                                @"SpellUserID":spellId,
                                @"Timestamp":timestamp,
                                @"Sign":sign};
        NSDictionary *rewardDic=@{@"m_GetSpellRewardPara":dataDic};
        [RequestTool requestDataWithType:@"post" andUrlString:@"Activity/GetSpellReward" andParameters:rewardDic andRequestFinished:^(id responses, NSError *error) {
            if (error) {
                [MBProgressHUD showError:@"未知错误，请稍后再试"];
            }
            if ([responses[@"IsSuccess"]intValue]==1) {
                [btn setTitle:@"已领取奖励" forState:UIControlStateNormal];
            }
        }];

    }
}
- (IBAction)clickOnDetail:(id)sender
{
    UIButton *btn=sender;
    if ([self.delegate respondsToSelector:@selector(goToControllerWithIndexPath:)])
    {
        [self.delegate goToControllerWithIndexPath:btn.tag];
    }
}

@end
